home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 138 / 138.xpi / chrome / stumbleupon.jar / content / passwordDialog.xul < prev    next >
Extensible Markup Language  |  2010-01-19  |  5KB  |  195 lines

  1. <?xml version="1.0"?>
  2.  
  3. <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
  4.  
  5. <!DOCTYPE window SYSTEM "chrome://stumbleupon/locale/stumbleupon.dtd" >
  6.  
  7. <dialog id="stumble_password_dialog" title="Change StumbleUpon Password"
  8.   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  9.   buttons="accept,cancel"
  10.   ondialogaccept="return handle_accept();"
  11.   onload="init()">
  12.  
  13. <script type="application/x-javascript">
  14. <![CDATA[
  15.  
  16. var detail;
  17. function init()
  18. {
  19.     detail = window.arguments[0];
  20. }
  21.  
  22. function handle_accept()
  23. {
  24.     var password0 = document.getElementById("password0").value;
  25.     var password1 = document.getElementById("password1").value;
  26.     var password2 = document.getElementById("password2").value;
  27.     var password = password1;
  28.     if (password1 != password2)
  29.     {
  30.         alert("The passwords don't match");
  31.         return false;
  32.     }
  33.     
  34.     if (password.length == 0)
  35.     {
  36.         alert("You cannot have a blank password");
  37.         return false;
  38.     }
  39.     
  40.     var res = opener.su_post_url_server_secure(
  41.                 "change_password.php",
  42.                 "username=" + detail.id +
  43.                 "&password=" + encodeURIComponent(password0) +
  44.                 "&newpassword=" + encodeURIComponent(password));
  45.  
  46.     if (res.status == 1)
  47.     {
  48.         alert("The stumbleupon.com server is currently down.\nPlease try again, and if you are still having difficulties,\ngo to http://www.stumbleupon.com/feedback.php to report the problem\nError : " + res.error + "\nStatus : " + res.status);
  49.         return false;
  50.     }
  51.  
  52.     if (res.status != 200)
  53.     {
  54.         alert("The stumbleupon.com server is currently down.\nPlease try again, and if you are still having difficulties,\ngo to http://www.stumbleupon.com/feedback.php to report the problem\nError : " + res.error + "\nStatus : " + res.status);
  55.         return false;
  56.     }
  57.  
  58.     var s = res.response;
  59.     
  60.     try {
  61.         if (opener.su_log_communication)
  62.             opener.su_log("response change_password.php", s);
  63.     } catch (e) {}
  64.  
  65.     // Split the response it username and pass
  66.     var ss;
  67.     if (s)
  68.     {
  69.         ss = s.split("\n")[0].split(" ");
  70.     }
  71.     else if (s != "")
  72.     {
  73.         alert("The stumbleupon.com server is currently down.\nPlease try again, and if you are still having difficulties,\ngo to http://www.stumbleupon.com/feedback.php to report the problem\nError : incomplete response");
  74.         return false;
  75.     }
  76.     else
  77.     {
  78.         ss = new Array();
  79.         ss[0] = "";
  80.     }
  81.  
  82.     if (ss[0] == "ERROR")
  83.     {
  84.         var ps = window.opener.su_get_service(
  85.                     "@mozilla.org/embedcomp/prompt-service;1",
  86.                     "nsIPromptService");
  87.         var msg = "An unknown error occurred trying to change your password.\r\n\r\nPlease try a different password.";
  88.  
  89.         if(ss[1])
  90.         {
  91.             if(ss[1] == "INCORRECT_PASSWORD")    
  92.             {
  93.                 var out = ps.confirmEx(
  94.                             window,
  95.                             "StumbleUpon Password Recovery",
  96.                             "The password you supplied was incorrect.\r\n\r\nWould you like to recover your username/password?",
  97.                             ps.STD_YES_NO_BUTTONS,
  98.                             null,
  99.                             null,
  100.                             null,
  101.                             null,
  102.                             {});
  103.                 if(out == 0)
  104.                 {
  105.                     var doc = opener.getBrowser().contentDocument;
  106.                     close();
  107.                     doc.location = opener.su_base_url + "recover_password.php";
  108.                 }
  109.                 // No additional messaging
  110.                 msg = "";
  111.             }
  112.             else if(ss[1] == "PASSWORD_IS_NICKNAME")
  113.             {
  114.                 msg = "You cannot use your nickname as your password.\r\n\r\nPlease try a different password.";
  115.             }
  116.             else if(ss[1] == "PASSWORD_TOO_WEAK")
  117.             {
  118.                 msg = "That password is too weak.\r\n\r\nPlease try a different password.";
  119.             }
  120.             else
  121.             {
  122.                 msg = "An unknown error occurred trying to change your password.\r\n\r\nPlease try a different password.";
  123.             }
  124.         }
  125.         if(msg != "")
  126.             ps.alert(window, "StumbleUpon", msg);
  127.         return false;
  128.     }
  129.         
  130.     detail.password = password;
  131.  
  132.     opener.setTimeout(function (parent, detail) { parent.su_handle_password_dialog_accept(detail); }, 0, opener, detail);
  133.     
  134.     return true;
  135. }
  136.  
  137.  
  138.  ]]>
  139. </script>
  140. <spacer height="10px"/>
  141. <hbox>
  142.     <spacer width="10px"/>
  143.     <image
  144.         width="32px"
  145.         height="32px"
  146.         src="chrome://stumbleupon/content/skin/ChangePassword.png"/>
  147.     <spacer width="5px"/>
  148.     <vbox>
  149.         <label value="Please enter a new password for your StumbleUpon"/>
  150.         <label value="account:"/>
  151.     </vbox>
  152. </hbox>
  153.  
  154. <grid flex="1" style="margin:10px">
  155.   <columns>
  156.     <column flex="2"/>
  157.     <column flex="1"/>
  158.   </columns>
  159.  
  160.   <rows>
  161.     <row>
  162.     <vbox align="right">
  163.         <spacer flex="1"/>
  164.         <label control="password0" value="Old Password:"/>
  165.         <spacer flex="1"/>
  166.     </vbox>
  167.     <textbox id="password0"
  168.             type="password"
  169.             maxlength="16"/>
  170.     </row>
  171.     <row>
  172.     <vbox align="right">
  173.         <spacer flex="1"/>
  174.         <label control="password1" value="New Password:"/>
  175.         <spacer flex="1"/>
  176.     </vbox>
  177.     <textbox id="password1"
  178.             type="password"
  179.             maxlength="16"/>
  180.     </row>
  181.     <row>
  182.     <vbox align="right">
  183.            <spacer flex="1"/>
  184.           <label control="password2" value="Retype New Password:"/>
  185.           <spacer flex="1"/>
  186.       </vbox>
  187.     <textbox id="password2"
  188.             type="password"
  189.             maxlength="16"/>
  190.     </row>
  191.   </rows>
  192. </grid>
  193.  
  194. </dialog>
  195.